package net.mihome.app.view;

import android.graphics.Bitmap;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MiHomeWebViewClient extends WebViewClient {
	public interface MihomeWebLinser{
		public void onLoadResource(WebView view, String url);
		public void onPageFinished(WebView view, String url) ;
		public void onPageStarted(WebView view, String url, Bitmap favicon) ;
		public void onReceivedError(WebView view, int errorCode,String description, String failingUrl) ;
	}
	private MihomeWebLinser mihomeWebLinser=null;
	@Override
	public boolean shouldOverrideUrlLoading(WebView view, String url) {
		view.loadUrl(url);
		return true;
	}
	@Override
	public void onLoadResource(WebView view, String url) {
		// TODO Auto-generated method stub
		super.onLoadResource(view, url);
		if(mihomeWebLinser!=null){
			mihomeWebLinser.onLoadResource(view, url);
		}
	}
	@Override
	public void onPageFinished(WebView view, String url) {
		// TODO Auto-generated method stub
		super.onPageFinished(view, url);
		if(mihomeWebLinser!=null){
			mihomeWebLinser.onPageFinished(view, url);
		}
	}
	@Override
	public void onPageStarted(WebView view, String url, Bitmap favicon) {
		// TODO Auto-generated method stub
		super.onPageStarted(view, url, favicon);
		if(mihomeWebLinser!=null){
			mihomeWebLinser.onPageStarted(view,url,favicon);
		}
	}
	@Override
	public void onReceivedError(WebView view, int errorCode,
			String description, String failingUrl) {
		// TODO Auto-generated method stub
		super.onReceivedError(view, errorCode, description, failingUrl);
		if(mihomeWebLinser!=null){
			mihomeWebLinser.onReceivedError(view, errorCode, description, failingUrl);
		}
	}
	public MihomeWebLinser getMihomeWebLinser() {
		return mihomeWebLinser;
	}
	public void setMihomeWebLinser(MihomeWebLinser mihomeWebLinser) {
		this.mihomeWebLinser = mihomeWebLinser;
	}
	
	
}
